<template>
	<view class="content">
		<heade title="注册" cross bg_color="bg_fff"></heade>
		<view class="position-relative">
			<image src="../../static/352.jpg" mode="" style="width: 750rpx;height: 450rpx;"></image>
			<view class="yaosClass position-center bg_fff d-flex align-center justify-content-center">
				<!-- <text class="iconfont icon-yuechi f-s50" style="color: #6db7fe;"></text> -->
				<image src="../../static/image/logo.png" mode="" style="width: 140rpx;height: 140rpx;border-radius: 20rpx;"></image>
			</view> 
		</view>
		
		<view class="m-l40 m-r40 m-t15">
			<view class="d-flex align-center justify-content-space-between p-b5" style="border-bottom: 2rpx solid #f6f6f6;">
				<text class="iconfont icon-qiye f-s20" style="color: #6db7fe;"></text>
				<view class="uni-input f-s14 flex1 m-l10">湖南巨龙商贸有限公司</view>
			</view>
			<view class="d-flex align-center m-t10 justify-content-space-between p-b10" style="border-bottom: 2rpx solid #f6f6f6;">
				<text class="iconfont icon-zhanghao f-s20 " style="color: #6db7fe;"></text>
				<input type="text" v-model="mobile" class="flex1 f-s14 m-l10" placeholder="请输入账号">
				<checkbox value="cb" checked="true"  style="transform:scale(0.7);" />
			</view>
			<view class="d-flex align-center m-t10 justify-content-space-between p-b10" style="border-bottom: 2rpx solid #f6f6f6;">
				<text class="iconfont icon-mima f-s20 " style="color: #6db7fe;"></text>
				<input type="text" v-model="password" password class="flex1 f-s14 m-l10" placeholder="请输入密码">
				<checkbox value="cb" checked="true"  style="transform:scale(0.7);" />
			</view>
			<view class="d-flex align-center m-t10 justify-content-space-between p-b10" style="border-bottom: 2rpx solid #f6f6f6;">
				<text class="iconfont icon-mima f-s20 " style="color: #6db7fe;"></text>
				<input type="text" v-model="password_1" password class="flex1 f-s14 m-l10" placeholder="请再次输入密码">
			</view>
			<view class="d-flex align-center m-t5 justify-content-space-between p-b5" style="border-bottom: 2rpx solid #f6f6f6;">
				<text class="iconfont icon-yanzhengyanzhengma f-s20 " style="color: #6db7fe;"></text>
				<view class="d-flex align-center flex1">
					<input type="text" v-model="code" class="flex1 f-s14 m-l10" placeholder="请输入验证码">
					<view class="authCode bg_4494EE d-flex align-center justify-content-center co_fff f-s13" @tap="code_init" style="width: 170rpx;margin: 0;">{{time != 60 ? time+'秒后获取' : '获取验证码'}}</view>
				</view>
			</view>
		</view> 
		<view>
			<view class="d-flex align-center justify-content-center paizhao m-t20" @tap="submit">
				<view class="f-s15 co_fff f-w500">立即注册</view>
			</view>
		</view>
		<view class="text-center f-s14 co_999 dinbu">
			<view class="m-t14">经销商：湖南巨龙商贸有限公司</view>
			<!-- <view class="m-t8">咨询服务：073184161520</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index:0,
				// array:['长沙千里眼公司','微趣互娱公司'],
				mobile:'',
				time:60,
				password:'',
				password_1:'',
				code:''
			}
		},
		onLoad() {
		},
		methods: {
			//获取验证码，间隔60s
			code_init(e) {
				var _this = this,
				mobile = RegExp(/^1[345789]\d{9}$/).test(this.mobile);
				if (mobile) {
					var request_data = {
						key:'ZCYZ',
						mobile: this.mobile,
					};
					this.disabled = true;
					uni.showLoading({
						title: '发送中'
					})
					this.$http.post('sms/send', request_data).then(res => {
						if (res.code == 1) {
							uni.hideLoading();
							uni.showToast({
								title: "短信已发送"
							});
							var data = setInterval(() => {
								this.time--;
								if (this.time == 0) {
									this.time = 60;
									this.disabled = false;
									clearInterval(data)
								}
							}, 1000)
						} else {
							this.disabled = false;
						}
					})
				} else {
					uni.showToast({
						icon: "none",
						title: '手机号码不对'
					});
				}
			},
			// 登录
			submit() {
				let mobile = RegExp(/^1[345789]\d{9}$/).test(this.mobile)
				if(!mobile) {
					return this.$common.show('请输入正确的手机号',true)
				}
				if(this.password == '') {
					return this.$common.show('请输入密码',true)
				}
				if(this.password != this.password_1) {
					return this.$common.show('请确认两次密码是否相同',true)
				}
				if(this.code == '') {
					return this.$common.show('请输入验证码',true)
				}
				let resData = {
					mobile:this.mobile,
					password:this.password,
					code:this.code,
					client:'6'
				}
				this.$http.post('account/register',resData).then(res => {
					if(res.code == 1) {
						this.$common.show('注册成功')
						setTimeout(() => {
							uni.navigateBack()
						},1000)
					}
				})
			},
			bindPickerChange(e) {
				this.index = e.detail.value
				// console.log(e.detail.value)
			}
		}
	}
</script>

<style lang="scss">
	.yaosClass{
		margin: 0 auto;
		// margin-top: -90rpx;
		width: 140rpx;
		height: 140rpx;
		z-index: 9;
		border-radius: 50%;
		box-shadow: 0px 2rpx 8rpx 0px rgba(111, 111, 111, 0.19);
	}
	/deep/ uni-checkbox .uni-checkbox-input{
		margin-right: 0 !important;
	}
	/deep/ uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
		border-color:#d1d1d1
	}
	.paizhao{
		width: 590rpx;
		height: 74rpx;
		background: #06aef5;
		border-radius: 74rpx;
		margin: 0 auto;
	}
	.paizhao1{
		width: 590rpx;
		height: 74rpx;
		border: 2rpx solid rgb(75, 196, 224);
		border-radius: 74rpx;
		margin: 0 auto;
	}
	.authCode{
		margin: 0 auto;
		width: 600rpx;
		height: 72rpx;
		border-radius: 16rpx;
		opacity: 1;
	}
	.dinbu{
		position: absolute;
		bottom: 40rpx;
		width: 100%;
		text-align: center;
	}
</style>